if exists (select 1
            from  sysobjects
           where  id = object_id('bd_kq_approve_annotation')
            and   type = 'U')
   drop table bd_kq_approve_annotation
go

/*==============================================================*/
/* Table: bd_kq_approve_annotation                              */
/*==============================================================*/
create table bd_kq_approve_annotation (
   id                   int                  identity,
   bill_id              int                  not null,
   bill_type            int                  not null,
   operator_id          int                  not null,
   notify_id            int                  not null,
   notify_content       varchar(max)         null,
   notify_time          datetime             null default getdate(),
   constraint PK_BD_KQ_APPROVE_ANNOTATION primary key (bill_id, bill_type, operator_id, notify_id)
)
go

if exists (select 1 from  sys.extended_properties
           where major_id = object_id('bd_kq_approve_annotation') and minor_id = 0)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_kq_approve_annotation'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '审批中心-审批知会',
   'user', @CurrentUser, 'table', 'bd_kq_approve_annotation'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_kq_approve_annotation')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'bill_id')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_kq_approve_annotation', 'column', 'bill_id'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '单据ID',
   'user', @CurrentUser, 'table', 'bd_kq_approve_annotation', 'column', 'bill_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_kq_approve_annotation')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'bill_type')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_kq_approve_annotation', 'column', 'bill_type'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '1：加班单
   2：请假单
   3：补出勤单',
   'user', @CurrentUser, 'table', 'bd_kq_approve_annotation', 'column', 'bill_type'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_kq_approve_annotation')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'operator_id')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_kq_approve_annotation', 'column', 'operator_id'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '知会人ID',
   'user', @CurrentUser, 'table', 'bd_kq_approve_annotation', 'column', 'operator_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_kq_approve_annotation')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'notify_id')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_kq_approve_annotation', 'column', 'notify_id'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '被知会人ID',
   'user', @CurrentUser, 'table', 'bd_kq_approve_annotation', 'column', 'notify_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_kq_approve_annotation')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'notify_content')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_kq_approve_annotation', 'column', 'notify_content'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '知会批注内容',
   'user', @CurrentUser, 'table', 'bd_kq_approve_annotation', 'column', 'notify_content'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_kq_approve_annotation')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'notify_time')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_kq_approve_annotation', 'column', 'notify_time'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '知会时间',
   'user', @CurrentUser, 'table', 'bd_kq_approve_annotation', 'column', 'notify_time'
go
